﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace Jy123.Web.PersonalInfo
{
    public partial class AlterCityIn : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int userID;
            string strUserIdFromCookie = Common.Cookie.getCookie("UserID");
            if (string.IsNullOrEmpty(strUserIdFromCookie))
            {
                Response.Redirect("/");
            }
            userID = int.Parse(strUserIdFromCookie);
            string msg = string.Empty;
            //个人主信息
            Jy123.Model.User_Main mUser = new Jy123.Model.User_Main();
            Jy123.BLL.User_Main bllUser = new Jy123.BLL.User_Main();
            mUser = bllUser.GetModel(userID);
            string strSave = Request.Form["hidsave"];
            if (strSave == "save")
            {
                string strProvince = Request.Form["selProvince"];            
                string strCity = Request.Form["selCity"];
                mUser.Province = Convert.ToInt32(strProvince);
                mUser.City = Convert.ToInt32(strCity);
                bllUser.Update(mUser);
                msg = "<script>$(function(){$.moonbox.ok('修改成功!');})</script>";
            }
            

            #region 页面初始化
            StringBuilder sbHtml = new StringBuilder(Cache["user_altercityin"].ToString());//最终写出页面的大sb
            sbHtml = sbHtml.Replace("$Header$", Cache["user_header"].ToString());//头部
            sbHtml = sbHtml.Replace("$Footer$", Cache["user_footer"].ToString());//底部
            sbHtml = sbHtml.Replace("$LeftUserCmd$", Cache["user_navigation_up"].ToString());//左侧导航
            sbHtml = sbHtml.Replace("$LeftUserFriendAdd$", Cache["user_friendadd"].ToString());//左侧直接添加好友
            sbHtml = sbHtml.Replace("$UserProvinceID$",mUser.Province.ToString());
            sbHtml = sbHtml.Replace("$UserCityID$",mUser.City.ToString());
            #endregion
            Response.Write(sbHtml.ToString()+msg);

        }
    }
}
